package exercise16;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MouseSetBackground extends JFrame{
	
	public MouseSetBackground(){
		JPanel p = new JPanel();
		add(p, BorderLayout.CENTER);
		addMouseListener(new MouseAdapter(){
			public void mousePressed(MouseEvent e){
				p.setBackground(Color.BLACK);
			}
			
			public void mouseReleased(MouseEvent e){
				p.setBackground(Color.GREEN);
			}
		});
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		MouseSetBackground frame = new MouseSetBackground();
		frame.setTitle("MouseSetBackground");
		frame.setSize(200,200);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		

	}

}
